﻿using System;
using System.Runtime.Remoting.Messaging;

namespace AEM.Data.BLL.Actions
{
    public static class SerialDataLog
    {
        static SerialDataLog()
        {
            Add = doAdd;
        }

        private static bool doAdd(SerialDataEventArgs args)
        {
            try
            {
                Actions.FaultLog.Add.BeginInvoke(args, new AsyncCallback(Actions.FaultLog.AddCallback), null);
                //添加故障记录 5大故障类型
                return true;
            }
            catch
            {
                //AEM.Utils.Log.WriteLog(AEM.Utils.Log.LogType.Info, ex.Message);
            }
            return false;
        }

        public static void AddCallback(IAsyncResult tag)
        {
            AsyncResult result = (AsyncResult)tag;
            Func<SerialDataEventArgs, bool> del = (Func<SerialDataEventArgs, bool>)result.AsyncDelegate;
            del.EndInvoke(tag);
        }

        /// <summary>
        /// 添加数据接收记录
        /// </summary>
        public static Func<SerialDataEventArgs, bool> Add;
    }
}
